<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="#">服务列表</a></li>
		</ul>
        <form class="well form-search" method="post" action="{:U('Businessservice/index')}">
            服务名:
            <input type="text" name="name" style="width: 100px;" value="{:I('request.name/s','')}" placeholder="请输入服务名">
            商户名:
            <input type="text" name="business_name" style="width: 100px;" value="{:I('request.business_name/s','')}" placeholder="请输入商户名">
            商户类型:
            <php>$type=I('type');</php>
            <select name="type" style="width: 100px;" >
                <option value="0">全部</option>
                <option value="1" <php>if($type==1){echo 'selected';}</php> >商户</option>
                <option value="2" <php>if($type==2){echo 'selected';}</php> >技师</option>
            </select>
            <br/>
            <br/>
            服务类型:
            <php>$sid = I('id');</php>
            <php>$cat_id =  I('cat_id');</php>
            <select id="cats" name="cat_id">
                <option value="0">全部</option>
                <option value="1" <php>if($cat_id==1){echo 'selected';}</php> >养护</option>
                <option value="2" <php>if($cat_id==2){echo 'selected';}</php> >救援</option>
                <option value="3" <php>if($cat_id==3){echo 'selected';}</php> >洗车</option>
                <option value="4" <php>if($cat_id==4){echo 'selected';}</php> >理赔</option>
            </select>
            <select name="id" id="childrenCats" style="display: none">
            </select>
            <br/>
            <br/>

            <input type="submit" class="btn btn-primary" value="搜索" id="sou"/>
            <a class="btn btn-danger" href="{:U('Businessservice/index')}">清空</a>
        </form>
		<form method="post" class="js-ajax-form">
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">ID</th>
						<th>服务名称</th>
						<th>服务价格</th>
						<th>服务是否擅长</th>
						<th>订单数</th>
						<th>真实订单数</th>
						<th>所属商户名</th>
						<th>所属分类</th>
						<th>服务创建时间</th>
						<th width="120">{:L('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
					<foreach name="services" item="vo">
					<tr>
						<td>{$vo.id}</td>
						<td>{$vo.name}</td>
						<td>{$vo.price}</td>
						<td><php>if($vo['good_at']==1){echo '擅长';}else{echo '';}</php></td>
						<td>{$vo.order_number}</td>
						<td>{$vo.true_order_number}</td>
						<td>{$vo.business_name}</td>
						<td>{$vo.service_name}</td>
						<td>{$vo.create_time|date="Y-m-d",###}</td>
						<td>
                            <a href="{:U('Businessservice/getDetails',array('id'=>$vo['id']))}">服务介绍</a> |
                            <a href="javascript:;" class="addOrderNumber" service_id="{$vo['id']}">添加订单数</a>
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
		</form>
		<div class="pagination">{$page}</div>
	</div>
    <div style="width: 489px;height:287px;text-align: center;position: absolute;margin-left: 50%;left: -240px;margin-top:50%;top:0px;display: none;z-index:9;border: 1px solid #fff" id="banDiv">
        <div style="height: 40px;background: #f7f8fa;padding-top: 15px;text-align: left;padding-left: 22px">添加订单数<button type="button" style="border:none;width: 14px;background: #f7f8fa;color: #ccc;padding-left: 400px" id="hideBan">X</button></div>
        <div style="background: #fff;text-align: center;height: 210px;padding-top:33px">
            <div style="width: 200px;text-align: right;color: #666666">请输入数量</div>
            <br>
            <input type="text" id="ban_number">
            <br>
            <button type="button" style="border:none;width: 215px;height: 30px;background: #19c571;color: #fff" id="ban">添加</button>
        </div>
    </div>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>
<script>
    //分类处理
    function changeCat(id) {
        var html="<option value='0'></option>";
        if(!id||id==0){
            $('#childrenCats').hide();
            $('#childrenCats').html(html);
            return;
        }
        $('#sou').css('background-color','#e95d4e');
        $('#sou').attr('disabled',"true");
        $.post("{:U('Businessservice/getChildrenServices')}",{id:id},function (r) {
            //加载子分类
            if(r.data.length!=0){
                $('#childrenCats').show();
                var new_html='';
                var len=r.data.length;
                for(var i=0;i<len;i++){
                    new_html+="<option value='"+r.data[i].id+"'>"+r.data[i].name+"</option>";
                }
                $('#childrenCats').html(new_html);
            }else{
                $('#childrenCats').hide();
                $('#childrenCats').html("<option value='"+id+"'></option>");
            }
            //选中子分类
            var len2=$('#childrenCats option').length;
            for(var d=0;d<len2;d++){
                if($('#childrenCats option').eq(d).val()=="{$sid}"){
                    $('#childrenCats option').eq(d).prop('selected',true);
                }
            }
            $('#sou').css('background-color','#33485d');
            $('#sou').removeAttr("disabled");
        });
    }
    //模拟选中分类
    changeCat({$cat_id});
    $('#cats').change(function () {
        var id=$(this).val();
        changeCat(id);
    });
</script>
<script>
    $('.addOrderNumber').click(function(r){
        var top=$(document).scrollTop();
        var height=$(window).height();
        height=parseInt(height)-132;
        top=-(height-parseInt(top));
        $('#banDiv').css('top',top);
        service_id=$(this).attr('service_id');
        $('#banDiv').show();
        $('#banZhe').show();
    });
    $('#hideBan').click(function(r){
        service_id=0;
        $('#banDiv').hide();
        $('#banZhe').hide();
    });
    $('#ban').click(function(r){
        var number=$('#ban_number').val();
        $.post('{:U("Businessservice/addOrderNumber")}',{id:service_id,number:number},function(r){
            alert(r.info);
/*            if(r.status==1){
                window.location.href="{:U('Business/checkBusinesses')}"
            }*/
             window.location.href = location.pathname + location.search;
        });
    });
</script>